/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Modelos;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author luisramirezmartinez SAMI 2011
 *
 */
@Entity
@Table(name = "tbl_clientes")
@NamedQueries({
    @NamedQuery(name = "TblClientes.findAll", query = "SELECT t FROM TblClientes t"),
    @NamedQuery(name = "TblClientes.findByIdcliente", query = "SELECT t FROM TblClientes t WHERE t.idcliente = :idcliente"),
    @NamedQuery(name = "TblClientes.findByRfc", query = "SELECT t FROM TblClientes t WHERE t.rfc = :rfc"),
    @NamedQuery(name = "TblClientes.findByNombre", query = "SELECT t FROM TblClientes t WHERE t.nombre = :nombre"),
    @NamedQuery(name = "TblClientes.findByApellidop", query = "SELECT t FROM TblClientes t WHERE t.apellidop = :apellidop"),
    @NamedQuery(name = "TblClientes.findByApellidom", query = "SELECT t FROM TblClientes t WHERE t.apellidom = :apellidom"),
    @NamedQuery(name = "TblClientes.findByTelefono", query = "SELECT t FROM TblClientes t WHERE t.telefono = :telefono"),
    @NamedQuery(name = "TblClientes.findByCorreo", query = "SELECT t FROM TblClientes t WHERE t.correo = :correo"),
    @NamedQuery(name = "TblClientes.findByEstatus", query = "SELECT t FROM TblClientes t WHERE t.estatus = :estatus")})
public class TblClientes implements Serializable {
    
  
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "Id_cliente")
    private Integer idcliente;
    @Basic(optional = false)
    @Column(name = "Rfc")
    private String rfc;
    @Basic(optional = false)
    @Column(name = "Nombre")
    private String nombre;
    @Basic(optional = false)
    @Column(name = "Apellido_p")
    private String apellidop;
    @Column(name = "Apellido_m")
    private String apellidom;
    @Column(name = "Telefono")
    private String telefono;
    @Column(name = "Correo")
    private String correo;
    @Column(name = "Estatus")
    private Boolean estatus;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idcliente")
    private List<TblDirecciones> tblDireccionesList;
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    
    public TblClientes(){

    }

    public TblClientes(Integer idcliente) {
        this.idcliente = idcliente;
    }

    public TblClientes(Integer idcliente, String rfc, String nombre, String apellidop) {
        this.idcliente = idcliente;
        this.rfc = rfc;
        this.nombre = nombre;
        this.apellidop = apellidop;
    }

    public Integer getIdcliente() {
        return idcliente;
    }

    public void setIdcliente(Integer idcliente) {
        Integer oldIdcliente = this.idcliente;
        this.idcliente = idcliente;
        changeSupport.firePropertyChange("idcliente", oldIdcliente, idcliente);
    }

    public String getRfc() {
        return rfc;
    }

    public void setRfc(String rfc) {
        String oldRfc = this.rfc;
        this.rfc = rfc;
        changeSupport.firePropertyChange("rfc", oldRfc, rfc);
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        String oldNombre = this.nombre;
        this.nombre = nombre;
        changeSupport.firePropertyChange("nombre", oldNombre, nombre);
    }

    public String getApellidop() {
        return apellidop;
    }

    public void setApellidop(String apellidop) {
        String oldApellidop = this.apellidop;
        this.apellidop = apellidop;
        changeSupport.firePropertyChange("apellidop", oldApellidop, apellidop);
    }

    public String getApellidom() {
        return apellidom;
    }

    public void setApellidom(String apellidom) {
        String oldApellidom = this.apellidom;
        this.apellidom = apellidom;
        changeSupport.firePropertyChange("apellidom", oldApellidom, apellidom);
    }

    public String getTelefono() {
        return telefono;
    }

    public void setTelefono(String telefono) {
        String oldTelefono = this.telefono;
        this.telefono = telefono;
        changeSupport.firePropertyChange("telefono", oldTelefono, telefono);
    }

    public String getCorreo() {
        return correo;
    }

    public void setCorreo(String correo) {
        String oldCorreo = this.correo;
        this.correo = correo;
        changeSupport.firePropertyChange("correo", oldCorreo, correo);
    }

    public Boolean getEstatus() {
        return estatus;
    }

    public void setEstatus(Boolean estatus) {
        Boolean oldEstatus = this.estatus;
        this.estatus = estatus;
        changeSupport.firePropertyChange("estatus", oldEstatus, estatus);
    }
    
    
    public String getNombreCorto(){
        return this.nombre+ " "+ this.apellidop;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idcliente != null ? idcliente.hashCode() : 0);
        return hash;
    }
    
    

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TblClientes)) {
            return false;
        }
        TblClientes other = (TblClientes) object;
        if ((this.idcliente == null && other.idcliente != null) || (this.idcliente != null && !this.idcliente.equals(other.idcliente))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return this.nombre +" "+this.apellidop+" "+this.apellidom;
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

    @XmlTransient
    public List<TblDirecciones> getTblDireccionesList() {
        return tblDireccionesList;
    }

    public void setTblDireccionesList(List<TblDirecciones> tblDireccionesList) {
        this.tblDireccionesList = tblDireccionesList;
    }

}
